/**
 * Created by Administrator on 2017/7/20.
 */
var vue = require('vue');
var vueRender = require('vue-server-renderer').createRenderer();
var server= require('express')();

server.get('*',function (req,res) {
  //第一步，创建一个vue实例
  var app = new vue({
    data: {
      url: req.url,
    },
    template: '<div>访问的url是：{{url}}</div>',
  });
  //第二步，创建一个render
  vueRender.renderToString(app, function(err, html){
    if(err){
      res.status(500).end('Internal Server Error');
    }
    res.end('<!DOCTYPE html><html lang="en"><head><title>Hello</title></head><body>${html}</body></html>')
  })
})
server.listen(8080);